﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Core;
using SharedGenomics.Annotations;
using SharedGenomics.Workbench.Core;

namespace SharedGenomics.Workbench.Services
{
    public class WCFAnnotationSessionService : WCFClientHost, IAnnotationSessionService
    {
        public Maybe<Guid[]> GetAnnotationSessionsForUserAndJob(int userId, int jobId)
        {
            return this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService, Guid[]>(s => s.GetAnnotationSessionsForUserAndJob(userId, jobId)).Just();
        }

        public Maybe<AnnotationSessionWithDescriptionInfo[]> GetAnnotationSessions()
        {
            return this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService, AnnotationSessionWithDescriptionInfo[]>(s => s.GetAnnotationSessions()).Just();
        }

        public Maybe<ViewedAnnotationInfo[]> GetViewedAnnotationsForSession(Guid annotationSessionId)
        {
            return this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService, ViewedAnnotationInfo[]>(s => s.GetViewedAnnotationsForSession(annotationSessionId)).Just();
        }

        public Maybe<ViewedAnnotationWithImageInfo[]> GetViewedAnnotationsWithImagesForSession(Guid annotationSessionId)
        {
            return this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService, ViewedAnnotationWithImageInfo[]>(s => s.GetViewedAnnotationsWithImagesForSession(annotationSessionId)).Just();
        }

        public void SetViewedAnnotationImportance(Guid viewedAnnotationId, bool isImportant)
        {
            this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService>(s => s.SetViewedAnnotationImportance(viewedAnnotationId, isImportant));
        }

        public void UploadPng(Guid viewedAnnotationId, byte[] data)
        {
            this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService>(s => s.UploadPng(viewedAnnotationId, data));
        }

        public void AddViewedAnnotation(Guid id, Guid annotationSessionId, Guid? parentViewedAnnotationId, DateTime createdDate, bool isImportant, string encodedKey, string description)
        {
            this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService>(s => s.AddViewedAnnotation(id, annotationSessionId, parentViewedAnnotationId, createdDate, isImportant, encodedKey, description));
        }

        public void AddAnnotationSession(Guid id, int jobId)
        {
            this.ExecuteProxyContract<AnnotationSessionService.IAnnotationSessionService>(s => s.AddAnnotationSession(id, jobId));
        }
    }
}
